package com.apptravel.dao;

import com.apptravel.entity.Hotel;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component("hotelDao")
public class HotelDAOImpl extends MybatisDao implements HotelDAO {

    public HotelDAOImpl() {
        super();
    }

    public int deleteById(Long id) {
        Hotel _key = new Hotel();
        _key.setId(id);
        int rows = getSqlSession().delete("hotel.deleteById", _key);
        return rows;
    }

    public void insert(Hotel record) {
        getSqlSession().insert("hotel.insert", record);
    }



    public Hotel selectById(Long id) {
        Hotel _key = new Hotel();
        _key.setId(id);
        Hotel record = (Hotel) getSqlSession().selectOne("hotel.selectById", _key);
        return record;
    }



    public int updateById(Hotel record) {
        int rows = getSqlSession().update("hotel.updateById", record);
        return rows;
    }

    public Page<Hotel> getList(Map<String,Object> params,int pageNo,int pageSize){
        params.put("page","");
        return this.selectPage("hotel.selectByMap",params,pageNo,pageSize);
    }

    public int deleteByMap(Map<String,Object> params){
        return this.getSqlSession().delete("hotel.deleteByMap",params);
    }

    public int updateByMap(Map<String,Object> params){
        int rows = getSqlSession().update("hotel.updateByMap",params);
        return rows;
    }
}